#ifndef __LEXER_H__
#define __LEXER_H__

#include "DFA.h"
#include <set>
#include <exception>

struct Token {
	std::string lexeme;
	std::string type;
	unsigned int row, column;

	Token();
	Token(std::string type);
	Token(unsigned int row, unsigned int col);
};

class Lexer {

	std::set<std::string> keywords;
	DFA characterDfa;
	std::ifstream programStream;
	unsigned int currentRow, currentColumn;

	static bool IsLineTerminator(Token);
	bool IsTokenValid(const Token&);

public:
	Lexer(const char *programfilename, const char *dfaFilename);
	~Lexer();

	Token PopNext();
};

// THE PROGRAM FILE FOR LEXER DOES NOT EXIST ON CONSTRUCTION
class ProgramFileNotFound : public std::exception {
	virtual const char* what() const throw() {
		return "The given program file not found.";
	}
};

#endif